<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>
<%@ page import="kr.co.insoft.core.service.menus.impl.MenuServiceImpl" %>
<%@ page import="kr.co.insoft.framework.config.MenuEntityModel" %>
<c:set var="CONTEXT">${pageContext.request.contextPath}</c:set>
<c:set var="cssUrl">${pageContext.request.contextPath}/resources/css</c:set>
<c:set var="jsUrl">${pageContext.request.contextPath}/resources/js</c:set>
<c:set var="imgUrl">${pageContext.request.contextPath}/resources/images</c:set>
<%MenuServiceImpl menuService = new MenuServiceImpl();
MenuEntityModel menus = menuService.getMenus();%>
<c:set var="menus" value="<%=menus %>"/>
<div class="navbar navbar-default navbar-fixed-top navbar-inverse yamm">
	<div class="navbar-header">
		<button type="button" data-toggle="collapse"
			data-target="#navbar-collapse-2" class="navbar-toggle">
			<span class="icon-bar"></span><span class="icon-bar"></span><span
				class="icon-bar"></span>
		</button>
		<a href="#" data-link="${CONTEXT }" class="navbar-brand btn_link"><img src="${imgUrl }/CloudMesh.png" width="30"/>&nbsp;<spring:message code="project.application.name"/></a>
	</div>
	<div id="navbar-collapse-2" class="navbar-collapse collapse">
		<ul class="nav navbar-nav">
			<c:forEach items="${menus.childs }" var="firstStepMenu">
				<li class="dropdown"><a href="#" data-toggle="dropdown"
				class="dropdown-toggle"><spring:message code="${firstStepMenu.menus.menuMsgName }"/><b class="caret"></b></a>
				<ul class="dropdown-menu">
					<li>
						<div class="yamm-content">
							<table class="table menuTable">
								<tbody>
								<c:forEach items="${firstStepMenu.childs }" var="secondStepMenu" varStatus="status">
								<c:if test="${(status.index) % 3 == 0}">
								<tr>
								</c:if>
									<td><h4><spring:message code="${secondStepMenu.menus.menuMsgName }"/></h4>
									<div><ul>
									<c:if test="${not empty secondStepMenu.childs }">
									<c:forEach items="${secondStepMenu.childs }" var="thirdStepMenu">
										<li><a href="#" data-link="${CONTEXT }${thirdStepMenu.menus.menuLink}" class="btn_link"><spring:message code="${thirdStepMenu.menus.menuMsgName }"/></a></li>
									</c:forEach>
									</c:if>
									</ul></div>
									</td>
								<c:if test="${(status.index) % 3 == 2}">
								</tr>
								</c:if>
								</c:forEach>
								</tbody>
							</table>
						</div>
					</li>
				</ul></li>
			</c:forEach>
		</ul>
		<ul class="nav navbar-nav navbar-right">
			<sec:authorize access="isAuthenticated()">
				<form class="navbar-form navbar-right" action="/j_spring_security_logout", method="post">
					<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}" />
                    <div class="form-group">
                        <span class="usernames btn_link tooltips" data-link="" data-toggle="tooltip" data-placement="bottom" title="뭐를 넣을까?">
                            <i class="fa fa-user"></i>&nbsp;<sec:authentication property="principal.nickname"/>&nbsp;
                        </span>
                    </div>
                    <div class="form-group">
                        <button class="btn btn-primary form-control" type="submit"><spring:message code="button.singout"/></button>
                    </div>
                </form>
			</sec:authorize>
		</ul>
	</div>
</div>